package com.ruoyi.web.controller.fire;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fire.domain.EBuildingFireHazard;
import com.ruoyi.fire.service.IEBuildingFireHazardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 建筑物火灾危险性Controller
 *
 * @author ruoyi
 * @date 2025-11-02
 */
@Api(value = "EBuildingFireHazardController",tags = "建筑物火灾危险性")
@RestController
@RequestMapping("/fire/hazard")
public class EBuildingFireHazardController extends BaseController {
    @Autowired
    private IEBuildingFireHazardService eBuildingFireHazardService;

    @ApiOperation("建筑物火灾危险性列表")
    @GetMapping("/allList")
    public AjaxResult allList() {
        return success(eBuildingFireHazardService.list());
    }

    /**
     * 查询建筑物火灾危险性列表
     */
    @PreAuthorize("@ss.hasPermi('system:hazard:list')")
    @GetMapping("/list")
    public TableDataInfo list(EBuildingFireHazard eBuildingFireHazard) {
        startPage();
        List<EBuildingFireHazard> list = eBuildingFireHazardService.selectEBuildingFireHazardList(eBuildingFireHazard);
        return getDataTable(list);
    }

    /**
     * 导出建筑物火灾危险性列表
     */
    @PreAuthorize("@ss.hasPermi('system:hazard:export')")
    @Log(title = "建筑物火灾危险性", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EBuildingFireHazard eBuildingFireHazard) {
        List<EBuildingFireHazard> list = eBuildingFireHazardService.selectEBuildingFireHazardList(eBuildingFireHazard);
        ExcelUtil<EBuildingFireHazard> util = new ExcelUtil<EBuildingFireHazard>(EBuildingFireHazard.class);
        util.exportExcel(response, list, "建筑物火灾危险性数据");
    }

    /**
     * 获取建筑物火灾危险性详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:hazard:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(eBuildingFireHazardService.selectEBuildingFireHazardById(id));
    }

    /**
     * 新增建筑物火灾危险性
     */
    @PreAuthorize("@ss.hasPermi('system:hazard:add')")
    @Log(title = "建筑物火灾危险性", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EBuildingFireHazard eBuildingFireHazard) {
        return toAjax(eBuildingFireHazardService.insertEBuildingFireHazard(eBuildingFireHazard));
    }

    /**
     * 修改建筑物火灾危险性
     */
    @PreAuthorize("@ss.hasPermi('system:hazard:edit')")
    @Log(title = "建筑物火灾危险性", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EBuildingFireHazard eBuildingFireHazard) {
        return toAjax(eBuildingFireHazardService.updateEBuildingFireHazard(eBuildingFireHazard));
    }

    /**
     * 删除建筑物火灾危险性
     */
    @PreAuthorize("@ss.hasPermi('system:hazard:remove')")
    @Log(title = "建筑物火灾危险性", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(eBuildingFireHazardService.deleteEBuildingFireHazardByIds(ids));
    }
}
